$(function () {
    request();
})
//获取消息信息
function request(){
    fetch("/userSystemMessage/getUserMessage", {
        credentials: 'include',
        method: "POST",
        headers: {
            'Content-Type': 'application/json'
        },
    }).then(function (response) {
        response.json().then(function (data) {
            if (data.res > 0) {
                var content = ''
                var date=""
                for (var i = 0; i < data.obj.length; i++) {
                    console.log(new Date(data.obj[i].sendDate))
                    content+="<ul class=\"am-avg-sm-1 font14 my_msg_ul\"> <li class=\"w100b radius10 bg-fff am-padding-sm am-margin-bottom-sm bottom-boshow3 posi-rela\"><ul class=\"am-avg-sm-1 line25\"><li class=\"ycsn\">"
                    content+="<b class='content'>"+data.obj[i].content+"</b></li><li class='font12 text-808080 times'>"+$.myTime.timeToDate(data.obj[i].sendDate)+"</li> </ul></li> </ul>"
                    date+="<div class=\"am-modal-dialog radius10\"><div class=\"am-modal-hd\">消息详情 <a href=\"javascript: void(0)\" class=\"am-close am-close-spin\" data-am-modal-close>&times;</a></div> <div class=\"am-modal-bd am-text-center\"></div></div>"

                }
                $("#content").html(content)
                $("#date").html(date)
                $("body .my_msg_ul").on('click', ">li", function () {
                    var html = "";
                    html += "<ul class='am-avg-sm-1 am-text-left font14'>";
                    html += "<li class='font12 text-808080 am-text-center' id='date'>"+$(this).find(".times").text()+"</li>";
                    html += "<li class='am-padding-xs am-padding-top-sm am-padding-bottom-lg' id='msg'>"+$(this).find(".content").text()+"</li>"
                    html += "</ul>";
                    $("#alert_model .am-modal-bd").html(html);
                    $('#alert_model').modal("open");
                })
            } else {
                return data.resMsg
            }
        });
    }).catch(function (e) {
        console.log(e);
    })
}